package ru.urfc.portal.model;

import javax.xml.bind.annotation.XmlTransient;

import ru.urfc.portal.dao.SpectrId;
import ru.urfc.portal.exceptions.UserGetItemException;
import ru.urfc.portal.model.accounting.Contragent;

public abstract class SpectrObjectWithCheck extends SpectrObject {

	@XmlTransient
	public abstract Contragent getContragent();

	@SuppressWarnings("unchecked")
	public <T extends SpectrObjectWithCheck> T check(SpectrId contragentId) {
		if (getContragent().getId().equals(contragentId.getId())) {
			return (T) this;
		}
		throw new UserGetItemException(getClass());
	}	
	
}